package com.gxa.sso.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.annotations.GeneratorType;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

// 描述实体类型常用的包名: pojo/entity/domain

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(exclude = {"password","salt"})
@Table(name = "tb_user")
/**
 * 将当前的实体类型标注,并在操作的时候自动生成数据表
 */
@Entity
@ApiModel("单点登录用户实体类型")
public class User implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="user_id")
    private Long id;

    @Column(name="user_name")
    private String name;

    @Column(name="user_phone")
    private String phone;

    @Column(name="user_password")
    // json转换时会忽略password字段
    @JsonIgnore
    private String password;
    @JsonIgnore
    private String salt;

    public String token;

    /**
     * 登录类型: 1.手机网页端 2.pc网页端 3.手机app端 4.小程序
     */
    @Column(name="login_type")
    private Integer loginType;

    /**
     * 用户状态 1.正常 2.禁用
     */
    @Column(name="user_status")
    private Integer status;

    /**
     * jpa按照驼峰命名规则转换为数据库规范: _
     */
    @Column(name="last_login_time")
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss",timezone = "GMT+8")
    public Date lastLoginTime;

    @Column(name="ip_address")
    public String ipAddress;


}
